package com.example.userservice.controller;

import com.example.communservice.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@RequestMapping("/user")
public class UserController {
    @GetMapping("getUserById")
    public User getUserById(@RequestParam Integer userId) {
        Random random = new Random();
        double v = random.nextDouble();
        if (v > 0.5) {
            v = 1 / 0;
        }
        return new User(userId, "测试用户");
    }


}
